<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>table2</title>
</head>
<body>
<table id="tbl">
    <tr>
        <td>姓名</td>
        <td>年龄</td>
        <td>性别</td>
        <td>段位</td>
        <td>编辑</td>
    </tr>
</table>
<button>添加</button>
<form id="ff">
    <input type="text" id="uname">
    <input type="button" value="确认" onclick="addtr()"><!--这个按钮不会提交-->

</form>
<script>
    var tbl=document.getElementById('tbl');
    var num=0;
    function addtr(){
        var uname=document.getElementById('uname');/*拿到文本框*/
        var str=`<tr id="haha${++num}">
        <td>${uname.value}</td>
        <td>18</td>
        <td>男</td>
        <td>黄金</td>
        <td><a href="javascript:del(${num})">删除</a>|<a>更新</a></td>
    </tr>`;
        tbl.innerHTML+=str;
    }
    function del(e){
        var tr=document.getElementById('haha'+e);
        tr.remove();
    }

</script>
</body>
</html>